package com.itboye.sunsun_china.www.aq;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;


@SuppressLint("NewApi") public class PeriodListActivity extends ActionBarActivity {

	Button mButtonLamp;
	Button mButtonPump;
	Button mButtonUvLamp;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_period_list);
		getSupportActionBar().setDisplayShowHomeEnabled(false);
		getSupportActionBar().setDisplayHomeAsUpEnabled(true);
		getSupportActionBar().setDisplayShowTitleEnabled(true);
		// 获取控件
		mButtonLamp = (Button) findViewById(R.id.period_list_button1);
		mButtonPump = (Button) findViewById(R.id.period_list_button2);
		mButtonUvLamp = (Button) findViewById(R.id.period_list_button3);

		// 照明灯单击处理
		mButtonLamp.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent mainIntent = new Intent(PeriodListActivity.this,
						PeriodActivity.class);
				mainIntent.putExtra("periodType", 1);
				PeriodListActivity.this.startActivity(mainIntent);
			}
		});

		// 冲浪泵单击处理
		mButtonPump.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent mainIntent = new Intent(PeriodListActivity.this,
						PeriodActivity.class);
				mainIntent.putExtra("periodType", 2);
				PeriodListActivity.this.startActivity(mainIntent);
			}
		});

		// 杀菌灯单击处理
		mButtonUvLamp.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent mainIntent = new Intent(PeriodListActivity.this,
						PeriodActivity.class);
				mainIntent.putExtra("periodType", 3);
				PeriodListActivity.this.startActivity(mainIntent);
			}
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.menu_period_list, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		int id = item.getItemId();
		if (id == android.R.id.home) {
			// 返回
			this.finish();
			return true;
		}
		return super.onOptionsItemSelected(item);
	}
}
